/************************************************************************

 This file is part of Chroma.

 EscapeFromPrisonPlanet is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 EscapeFromPrisonPlanet is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

************************************************************************/

// All code (c)2013 Scott Bevin. all rights reserved

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace LudumDare26.PrimitiveRendering
{
	public enum PEPrimitiveType
	{
		Line,
		Triangle,
		Circle,
		Rectangle,
		Polygon,
		Curve,
		String,
	}

	public abstract class PEPrimitive : IComparable<PEPrimitive>
	{
		public Vector2 Position { get; set; }

		public float Rotation { get; set; }

		public Color BorderColor;

		public float BorderWidth { get; set; }

		public bool IsFilled { get; set; }

		public Color FillColor;

		public float Layer { get; set; }

		public PEPrimitiveType Type { get; protected set; }

		public abstract int PrimitiveCount { get; }

		public static Comparison<PEPrimitive> LayerComparison = delegate(PEPrimitive p1, PEPrimitive p2)
		{
			return p2.Layer.CompareTo(p1.Layer);
		};

		public abstract bool Intersection(PEPrimitive primitive);

		public abstract bool Inside(Vector2 point);

		public abstract void CreateUV();

		public abstract void Draw(ref VertexPositionColorTexture[] vertices, ref int vertexIndex, ref short[] indices, ref int indiceIndex);

		#region IComparable<PEPrimitive> Members

		public int CompareTo(PEPrimitive other)
		{
			return other.Layer.CompareTo(this.Layer);
		}

		#endregion IComparable<PEPrimitive> Members
	}
}